package com.example.jt_manager_service;

import com.example.jt_manager_mapper.ItemCatMapper;
import com.example.jt_manager_pojo.ItemCat;
import com.example.jt_manager_pojo.ItemCatExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService{

    @Autowired
    ItemCatMapper itemCatMapper;

//    SELECT * FROM tb_item_cat WHERE STATUS=1 AND parent_id=0
//    ORDER BY parent_id,sort_order;
    @Override
    public List<ItemCat> queryGoodsCategory(long id) {
        ItemCatExample itemCatExample= new ItemCatExample();
        itemCatExample.setOrderByClause("parent_id");
        itemCatExample.setOrderByClause("sort_order");
        itemCatExample.createCriteria().andStatusEqualTo(1).andParentIdEqualTo(id);
        List<ItemCat> itemCats = itemCatMapper.selectByExample(itemCatExample);
        return itemCats;

//        List<ItemCat> itemCats = itemCatMapper.queryCategoryList(id);
//        return itemCats;

    }
}
